--package.path = package.path .. ";../?.lua"
package.path = package.path .. ";C:/Users/win/Documents/_lua/util/?.lua"

local Stack = require("Stack")

function Test1()
    local s = Stack.new()
    assert(0 == s:GetCount())
    assert(nil == s:Peek())

    s:Push("one")
    assert(1 == s:GetCount())
    assert("one" == s:Peek())
    assert("one" == s:Pop())
    assert(0 == s:GetCount())

    s:Push("one")
    s:Push("1")
    s:Push("two")
    assert(3 == s:GetCount())
    assert("two" == s:Peek())

    assert("two" == s:Pop())
    assert(2 == s:GetCount())
    assert("1" == s:Pop())
    assert(1 == s:GetCount())
    assert("one" == s:Pop())
    assert(0 == s:GetCount())
    assert(nil == s:Peek())

    for i=1,100 do
        s:Push(i)
    end
    assert(100 == s:GetCount())
    s:Clear()
    assert(0 == s:GetCount())
end
Test1()


function Test2()
    local s = Stack.new()
    s:Push("one")
    s:Push("1")
    s:Push("two")
    assert(3 == s:GetCount())
    assert("two" == s:Peek())

    local s2 = Stack.new2(s)
    assert(3 == s2:GetCount())
    assert("two" == s2:Peek())

    for v in s2:GetIterator() do
        print("v: ", v)
    end
end
Test2()